package api

import (
	"api_gateway/basic/config"
	__ "api_gateway/basic/proto"
	"api_gateway/handler/request"
	"github.com/gin-gonic/gin"
	"net/http"
)

func VideoList(c *gin.Context) {
	var req request.VideoList
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": "验证失败",
			"data":    err.Error(),
		})
		return
	}
	list, err := config.NetWorkClient.VideoHotList(c, &__.VideoHotListReq{
		Page:      int64(req.Page),
		PageSize:  int64(req.PageSize),
		VideoType: req.VideoType,
	})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": "列表查询失败",
			"data":    err.Error(),
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "查询成功",
		"data":    list,
	})
}

func VideoListStatus(context *gin.Context) {

}

func CourseDetail(c *gin.Context) {
	var req request.CourseDetail
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": "验证失败",
			"data":    err.Error(),
		})
		return
	}
	detail, _ := config.NetWorkClient.CourseDetail(c, &__.CourseDetailReq{Id: int64(req.Id)})
	c.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "详情展示成功",
		"data":    detail,
	})
}

func MyList(c *gin.Context) {
	var req request.CourseDetail
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": "验证失败",
			"data":    err.Error(),
		})
		return
	}
	mylist, _ := config.NetWorkClient.GetUserMyCollect(c, &__.GetUserMyCollectReq{
		UserId: int64(req.Id),
	})
	c.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "我的收藏展示成功",
		"data":    mylist,
	})
}
